package co.yixiang.mall.common.feign;

import co.yixiang.common.core.api.ApiResult;
import co.yixiang.common.core.constant.ServiceNameConstants;
import co.yixiang.mall.common.hystrix.RemoteMemberUserFallbackFactory;
import co.yixiang.mall.common.mall.domain.YxUser;
import co.yixiang.mall.common.mall.param.HLoginParam;
import co.yixiang.weixin.common.weixin.vo.LoginParam;
import co.yixiang.mall.common.mall.param.RegParam;
import co.yixiang.mall.common.mall.param.VerityParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 用户服务
 *
 * @author yshop
 */
@FeignClient(contextId = "remoteMemberUserService", value = ServiceNameConstants.MALL_SERVICE, fallbackFactory = RemoteMemberUserFallbackFactory.class)
public interface RemoteMemberUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param loginParam LoginParam
     * @return 结果
     */
    @PostMapping(value = "/api/auth/login")
    ApiResult<YxUser> HLogin(@RequestBody HLoginParam loginParam);


    /**
     * 保存用户登录信息远程接口


     * @return
     */
    @PostMapping("/api/auth/saveLoginOnUser")
    void saveLoginOnUser(@RequestBody YxUser yxUser, @RequestParam(value = "token") String token);

    /**
     * 微信小程序授权登录
     *
     * @param loginParam LoginParam
     * @return 结果
     */
    @PostMapping(value = "/api/auth/wxapp/auth")
    ApiResult<YxUser> wxappLogin(@RequestBody LoginParam loginParam);


    /**
     * 微信公众号授权
     */
    @GetMapping("/api/auth/wechat/auth")
    ApiResult<YxUser> authLogin(@RequestParam(value = "code") String code,
                                @RequestParam(value = "spread") String spread);

    /**
     * H5/APP注册新用户
     * @param param
     * @return
     */
    @PostMapping("/api/auth/register")
    ApiResult<String> register(@RequestBody RegParam param);

    /**
     * 短信验证码发送
     * @param param
     * @return
     */
    @PostMapping("/api/auth/register/verify")
    ApiResult<String> verify(@RequestBody VerityParam param);

    /**
     * 通过用户名查询用户信息
     *
     * @param username username
     * @return 结果
     */
    @GetMapping(value = "/api/auth/getUserInfo/{username}")
    ApiResult<YxUser> getUserInfo(@PathVariable("username") String username);

    /**
     * 根据用户id获取用户信息
     *
     * @param uid
     * @return
     */
    @GetMapping(value = "/yxUser/getUserByUid")
    YxUser getUserByUid(@RequestParam(value = "uid") Long uid);

    /**
     * 修改用户
     *
     * @param yxUser
     */
    @PostMapping("/user/updateById")
    void updateById(@RequestBody YxUser yxUser);


    /**
     * 查询所有用户信息
     *
     * @return Map<Long, YxUser>
     */
    @GetMapping(value = "/yxUser/getAllUserMap")
    Map<Long, YxUser> getAllUserMap();

}
